<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>可视化终端控制界面</title>
    <link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@400&display=swap" rel="stylesheet">
    <style>
        body {
            background-color: #ffffff; /* 白色背景 */
            color: #333; /* 深色字体 */
            font-family: 'Open Sans', sans-serif; /* 使用简约字体 */
            margin: 0;
            padding: 0;
            transition: background-color 0.3s ease;
        }

        /* Logo样式 */
        #logo {
            top: 20px;
            left: 20px;
            width: 150px; /* 调整宽度，增加到150px */
            height: auto; /* 保持高度自动 */
            position: relative;
        }

        /*标题*/
        h1 {
            font-size: 48px; /* 调整标题字体大小 */
            color: #007BFF; /* 蓝色标题 */
            text-align: center;
            margin: 20px 0;
        }

        /* 导航栏样式 */
        #navbar {
            display: flex;
            justify-content: center;
            background-color: #007BFF; /* 蓝色背景 */
            padding: 10px 0;
        }

        .nav-link {
            color: white; /* 白色字体 */
            text-decoration: none;
            margin: 0 20px;
            font-size: 18px; /* 导航链接字体大小 */
            transition: color 0.3s;
        }

        .nav-link:hover {
            text-decoration: underline; /* 悬停时下划线 */
        }

        /*右上角登录按钮*/
        #greetButton {
            position: fixed;
            top: 20px;
            right: 20px;
            padding: 10px 20px;
            font-size: 16px;
            color: white;
            background-color: #007BFF; /* 蓝色按钮 */
            border: none;
            border-radius: 5px;
            cursor: pointer;
            transition: background-color 0.3s;
        }

        #greetButton:hover {
            background-color: #0056b3; /* 按钮悬停变色 */
        }

        /* 模态框样式 */
        #modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.5);
            justify-content: center;
            align-items: center;
            z-index: 1000;
        }

        #modalContent {
            background-color: white;
            padding: 20px;
            border-radius: 5px;
            text-align: center;
            z-index: 1001;
        }

        #closeButton {
            margin-top: 10px;
        }

        .carousel-image {
            min-width: 100%;
            height: 100%;
            object-fit: cover;
            transition: opacity 0.5s ease;
            position: absolute;
            top: 0;
            left: 0;
            opacity: 0;
        }

        /* 题目样式 */
        #titles {
            margin: 20px auto;
            width: 80%;
            text-align: center;
        }

        .title-link {
            display: block;
            font-size: 20px; /* 调整链接字体大小 */
            margin: 5px 0;
            color: #007BFF; /* 蓝色链接 */
            text-decoration: none;
            transition: color 0.3s;
        }

        .title-link:hover {
            color: #0056b3; /* 悬停时变色 */
        }

        h2 {
            color: green; /* 设置h2字体颜色 */
            font-size: 24px; /* 设置h2字体大小 */
        }

        p {
            font-size: 16px; /* 设置p字体大小 */
        }

        /* 用户输入区域样式 */
        #userInputSection {
            margin: 40px auto;
            width: 80%;
            text-align: center;
        }

        #userInput {
            padding: 10px;
            font-size: 16px;
            width: 60%;
        }

        #confirmInputButton {
            padding: 10px 15px;
            font-size: 16px;
            margin-left: 10px;
            background-color: #9FEC25; /* 按钮颜色 */
            color: #333;
            border: none;
            border-radius: 5px;
            cursor: pointer;
        }

        #userInputDisplay {
            margin: 40px auto;
            width: 60%;
            text-align: center;
        }
    </style>
</head>
<body>
    <img id="logo" src="logo.jpg" alt="Logo">
    <button id="greetButton">登录/注册</button>
    <h1>无人机激光环割操作界面</h1>

    <!-- 导航栏 -->
    <div id="navbar">
        <a href="#" class="nav-link">首页</a>
        <a href="#" class="nav-link">咨询</a>
        <a href="#" class="nav-link">更多</a>
        <a href="#" class="nav-link">讨论区</a>
        <a href="#" class="nav-link">关于我们</a>
        <a href="#" class="nav-link">联系</a>
    </div>

    <p id="greetingMessage"></p>

    <!-- 模态框 -->
    <div id="modal">
        <div id="modalContent">
            <p>请输入您的昵称：</p>
            <input type="text" id="nameInput" placeholder="您的昵称">
            <p>请输入您的密码：</p>
            <input type="password" id="passwordInput" placeholder="您的密码">
            <p>确认您的密码：</p>
            <input type="password" id="confirmPasswordInput" placeholder="再次输入您的密码">
            <button id="submitButton">登录/注册</button>
            <button id="closeButton">关闭</button>
        </div>
    </div>

    <script>
        const greetButton = document.getElementById('greetButton');
        const modal = document.getElementById('modal');
        const nameInput = document.getElementById('nameInput');
        const passwordInput = document.getElementById('passwordInput');
        const confirmPasswordInput = document.getElementById('confirmPasswordInput');
        const greetingMessage = document.getElementById('greetingMessage');
        const submitButton = document.getElementById('submitButton');
        const closeButton = document.getElementById('closeButton');

        const carouselImages = document.querySelectorAll('.carousel-image');
        let currentImageIndex = 0;

        function showImage(index) {
            carouselImages.forEach((img, i) => {
                img.classList.remove('active');
                if (i === index) {
                    img.classList.add('active');
                }
            });
        }

        function showNextImage() {
            currentImageIndex = (currentImageIndex + 1) % carouselImages.length;
            showImage(currentImageIndex);
        }

        function showPrevImage() {
            currentImageIndex = (currentImageIndex - 1 + carouselImages.length) % carouselImages.length;
            showImage(currentImageIndex);
        }

        document.getElementById('leftArrow').addEventListener('click', showPrevImage);
        document.getElementById('rightArrow').addEventListener('click', showNextImage);

        submitButton.addEventListener('click', function () {
            const name = nameInput.value;
            const password = passwordInput.value;
            const confirmPassword = confirmPasswordInput.value;

            // 简单的密码验证逻辑
            if (name && password && password === confirmPassword) {
                sessionStorage.setItem('username', name); // 保存用户名到 sessionStorage
                greetingMessage.textContent = `恭喜，${name}！登录成功！`;
                modal.style.display = 'none'; // 关闭模态框
                greetButton.style.display = 'none'; // 隐藏登录按钮
            } else {
                greetingMessage.textContent = "请确保输入的密码匹配。";
            }
            nameInput.value = ''; // 清空输入框
            passwordInput.value = ''; // 清空输入框
            confirmPasswordInput.value = ''; // 清空输入框
        });

        closeButton.addEventListener('click', function () {
            modal.style.display = 'none'; // 关闭模态框
            nameInput.value = ''; // 清空输入框
            passwordInput.value = ''; // 清空输入框
            confirmPasswordInput.value = ''; // 清空输入框
        });

        // 用户输入处理
        const userInput = document.getElementById('userInput');
        const confirmInputButton = document.getElementById('confirmInputButton');
        const userInputOutput = document.getElementById('userInputOutput');

        confirmInputButton.addEventListener('click', function () {
            const inputText = userInput.value.trim(); // 获取输入的内容并去除前后空格
            if (inputText) {
                userInputOutput.textContent = inputText; // 显示用户输入的内容
                userInput.value = ''; // 清空输入框
            } else {
                alert("请输入有效内容！"); // 提示用户输入有效内容
            }
        });
    </script>
</body>
</html>
